home *** CD-ROM | disk | FTP | other *** search
/ Digitalfoto 118 / Digitalfoto 118.iso / mac / programas / 00 / start.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Text File  |  2009-11-16  |  60KB  |  1,816 lines

  1. class mx.video.VideoPlayer extends MovieClip
  2. {
  3.    static var version = "1.0.1.10";
  4.    static var shortVersion = "1.0.1";
  5.    static var DISCONNECTED = "disconnected";
  6.    static var STOPPED = "stopped";
  7.    static var PLAYING = "playing";
  8.    static var PAUSED = "paused";
  9.    static var BUFFERING = "buffering";
  10.    static var LOADING = "loading";
  11.    static var CONNECTION_ERROR = "connectionError";
  12.    static var REWINDING = "rewinding";
  13.    static var SEEKING = "seeking";
  14.    static var RESIZING = "resizing";
  15.    static var EXEC_QUEUED_CMD = "execQueuedCmd";
  16.    static var BUFFER_EMPTY = "bufferEmpty";
  17.    static var BUFFER_FULL = "bufferFull";
  18.    static var BUFFER_FLUSH = "bufferFlush";
  19.    static var DEFAULT_INCMANAGER = "mx.video.NCManager";
  20.    static var DEFAULT_UPDATE_TIME_INTERVAL = 250;
  21.    static var DEFAULT_UPDATE_PROGRESS_INTERVAL = 250;
  22.    static var DEFAULT_IDLE_TIMEOUT_INTERVAL = 300000;
  23.    static var AUTO_RESIZE_INTERVAL = 100;
  24.    static var AUTO_RESIZE_PLAYHEAD_TIMEOUT = 0.5;
  25.    static var AUTO_RESIZE_METADATA_DELAY_MAX = 5;
  26.    static var FINISH_AUTO_RESIZE_INTERVAL = 250;
  27.    static var RTMP_DO_STOP_AT_END_INTERVAL = 500;
  28.    static var RTMP_DO_SEEK_INTERVAL = 100;
  29.    static var HTTP_DO_SEEK_INTERVAL = 250;
  30.    static var HTTP_DO_SEEK_MAX_COUNT = 4;
  31.    static var CLOSE_NS_INTERVAL = 0.25;
  32.    static var HTTP_DELAYED_BUFFERING_INTERVAL = 100;
  33.    static var PLAY = 0;
  34.    static var LOAD = 1;
  35.    static var PAUSE = 2;
  36.    static var STOP = 3;
  37.    static var SEEK = 4;
  38.    function VideoPlayer()
  39.    {
  40.       super();
  41.       mx.events.EventDispatcher.initialize(this);
  42.       this._state = mx.video.VideoPlayer.DISCONNECTED;
  43.       this._cachedState = this._state;
  44.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  45.       this._sawPlayStop = false;
  46.       this._cachedPlayheadTime = 0;
  47.       this._metadata = null;
  48.       this._startingPlay = false;
  49.       this._invalidSeekTime = false;
  50.       this._invalidSeekRecovery = false;
  51.       this._currentPos = 0;
  52.       this._atEnd = false;
  53.       this._cmdQueue = new Array();
  54.       this._readyDispatched = false;
  55.       this._autoResizeDone = false;
  56.       this._lastUpdateTime = -1;
  57.       this._sawSeekNotify = false;
  58.       this._updateTimeIntervalID = 0;
  59.       this._updateTimeInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_TIME_INTERVAL;
  60.       this._updateProgressIntervalID = 0;
  61.       this._updateProgressInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_PROGRESS_INTERVAL;
  62.       this._idleTimeoutIntervalID = 0;
  63.       this._idleTimeoutInterval = mx.video.VideoPlayer.DEFAULT_IDLE_TIMEOUT_INTERVAL;
  64.       this._autoResizeIntervalID = 0;
  65.       this._rtmpDoStopAtEndIntervalID = 0;
  66.       this._rtmpDoSeekIntervalID = 0;
  67.       this._httpDoSeekIntervalID = 0;
  68.       this._httpDoSeekCount = 0;
  69.       this._finishAutoResizeIntervalID = 0;
  70.       this._delayedBufferingIntervalID = 0;
  71.       this._delayedBufferingInterval = mx.video.VideoPlayer.HTTP_DELAYED_BUFFERING_INTERVAL;
  72.       if(this._isLive == undefined)
  73.       {
  74.          this._isLive = false;
  75.       }
  76.       if(this._autoSize == undefined)
  77.       {
  78.          this._autoSize = false;
  79.       }
  80.       if(this._aspectRatio == undefined)
  81.       {
  82.          this._aspectRatio = true;
  83.       }
  84.       if(this._autoPlay == undefined)
  85.       {
  86.          this._autoPlay = true;
  87.       }
  88.       if(this._autoRewind == undefined)
  89.       {
  90.          this._autoRewind = true;
  91.       }
  92.       if(this._bufferTime == undefined)
  93.       {
  94.          this._bufferTime = 0.1;
  95.       }
  96.       if(this._volume == undefined)
  97.       {
  98.          this._volume = 100;
  99.       }
  100.       this._sound = new Sound(this);
  101.       this._sound.setVolume(this._volume);
  102.       this.__visible = true;
  103.       this._hiddenForResize = false;
  104.       this._hiddenForResizeMetadataDelay = 0;
  105.       this._contentPath = "";
  106.    }
  107.    function setSize(w, h)
  108.    {
  109.       if(w == this._video._width && h == this._video._height || this._autoSize)
  110.       {
  111.          return undefined;
  112.       }
  113.       this._video._width = w;
  114.       this._video._height = h;
  115.       if(this._aspectRatio)
  116.       {
  117.          this.startAutoResize();
  118.       }
  119.    }
  120.    function setScale(xs, ys)
  121.    {
  122.       if(xs == this._video._xscale && ys == this._video._yscale || this._autoSize)
  123.       {
  124.          return undefined;
  125.       }
  126.       this._video._xscale = xs;
  127.       this._video._yscale = ys;
  128.       if(this._aspectRatio)
  129.       {
  130.          this.startAutoResize();
  131.       }
  132.    }
  133.    function play(url, isLive, totalTime)
  134.    {
  135.       if(url != null && url != undefined)
  136.       {
  137.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  138.          {
  139.             this._state = this._cachedState;
  140.          }
  141.          else
  142.          {
  143.             if(!this.__get__stateResponsive())
  144.             {
  145.                this.queueCmd(mx.video.VideoPlayer.PLAY,url,isLive,totalTime);
  146.                return undefined;
  147.             }
  148.             this.execQueuedCmds();
  149.          }
  150.          this._autoPlay = true;
  151.          this._load(url,isLive,totalTime);
  152.          return undefined;
  153.       }
  154.       if(!this.isXnOK())
  155.       {
  156.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined))
  157.          {
  158.             this.flushQueuedCmds();
  159.             this.queueCmd(mx.video.VideoPlayer.PLAY);
  160.             this.setState(mx.video.VideoPlayer.LOADING);
  161.             this._cachedState = mx.video.VideoPlayer.LOADING;
  162.             this._ncMgr.reconnect();
  163.             return undefined;
  164.          }
  165.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  166.       }
  167.       else
  168.       {
  169.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  170.          {
  171.             this._state = this._cachedState;
  172.          }
  173.          else
  174.          {
  175.             if(!this.__get__stateResponsive())
  176.             {
  177.                this.queueCmd(mx.video.VideoPlayer.PLAY);
  178.                return undefined;
  179.             }
  180.             this.execQueuedCmds();
  181.          }
  182.          if(this._ns == null || this._ns == undefined)
  183.          {
  184.             this._createStream();
  185.             this._video.attachVideo(this._ns);
  186.             this.attachAudio(this._ns);
  187.          }
  188.          switch(this._state)
  189.          {
  190.             case mx.video.VideoPlayer.BUFFERING:
  191.                if(this._ncMgr.isRTMP())
  192.                {
  193.                   this._play(0);
  194.                   if(this._atEnd)
  195.                   {
  196.                      this._atEnd = false;
  197.                      this._currentPos = 0;
  198.                      this.setState(mx.video.VideoPlayer.REWINDING);
  199.                   }
  200.                   else if(this._currentPos > 0)
  201.                   {
  202.                      this._seek(this._currentPos);
  203.                      this._currentPos = 0;
  204.                   }
  205.                }
  206.             case mx.video.VideoPlayer.PLAYING:
  207.                return undefined;
  208.             case mx.video.VideoPlayer.STOPPED:
  209.                if(this._ncMgr.isRTMP())
  210.                {
  211.                   if(this._isLive)
  212.                   {
  213.                      this._play(-1);
  214.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  215.                   }
  216.                   else
  217.                   {
  218.                      this._play(0);
  219.                      if(this._atEnd)
  220.                      {
  221.                         this._atEnd = false;
  222.                         this._currentPos = 0;
  223.                         this._state = mx.video.VideoPlayer.BUFFERING;
  224.                         this.setState(mx.video.VideoPlayer.REWINDING);
  225.                      }
  226.                      else if(this._currentPos > 0)
  227.                      {
  228.                         this._seek(this._currentPos);
  229.                         this._currentPos = 0;
  230.                         this.setState(mx.video.VideoPlayer.BUFFERING);
  231.                      }
  232.                      else
  233.                      {
  234.                         this.setState(mx.video.VideoPlayer.BUFFERING);
  235.                      }
  236.                   }
  237.                }
  238.                else
  239.                {
  240.                   this._pause(false);
  241.                   if(this._atEnd)
  242.                   {
  243.                      this._atEnd = false;
  244.                      this._seek(0);
  245.                      this._state = mx.video.VideoPlayer.BUFFERING;
  246.                      this.setState(mx.video.VideoPlayer.REWINDING);
  247.                   }
  248.                   else if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  249.                   {
  250.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  251.                   }
  252.                   else
  253.                   {
  254.                      this.setState(mx.video.VideoPlayer.PLAYING);
  255.                   }
  256.                }
  257.                break;
  258.             case mx.video.VideoPlayer.PAUSED:
  259.                this._pause(false);
  260.                if(!this._ncMgr.isRTMP())
  261.                {
  262.                   if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  263.                   {
  264.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  265.                   }
  266.                   else
  267.                   {
  268.                      this.setState(mx.video.VideoPlayer.PLAYING);
  269.                   }
  270.                }
  271.                else
  272.                {
  273.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  274.                }
  275.          }
  276.       }
  277.    }
  278.    function load(url, isLive, totalTime)
  279.    {
  280.       if(url == null || url == undefined)
  281.       {
  282.          throw new Error("null url sent to VideoPlayer.load");
  283.       }
  284.       else
  285.       {
  286.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  287.          {
  288.             this._state = this._cachedState;
  289.          }
  290.          else
  291.          {
  292.             if(!this.__get__stateResponsive())
  293.             {
  294.                this.queueCmd(mx.video.VideoPlayer.LOAD,url,isLive,totalTime);
  295.                return undefined;
  296.             }
  297.             this.execQueuedCmds();
  298.          }
  299.          this._autoPlay = false;
  300.          this._load(url,isLive,totalTime);
  301.       }
  302.    }
  303.    function _load(url, isLive, totalTime)
  304.    {
  305.       this._prevVideoWidth = this.videoWidth;
  306.       if(this._prevVideoWidth == undefined)
  307.       {
  308.          this._prevVideoWidth = this._video.width;
  309.          if(this._prevVideoWidth == undefined)
  310.          {
  311.             this._prevVideoWidth = 0;
  312.          }
  313.       }
  314.       this._prevVideoHeight = this.videoHeight;
  315.       if(this._prevVideoHeight == undefined)
  316.       {
  317.          this._prevVideoHeight = this._video.height;
  318.          if(this._prevVideoHeight == undefined)
  319.          {
  320.             this._prevVideoHeight = 0;
  321.          }
  322.       }
  323.       this._autoResizeDone = false;
  324.       this._cachedPlayheadTime = 0;
  325.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  326.       this._sawPlayStop = false;
  327.       this._metadata = null;
  328.       this._startingPlay = false;
  329.       this._invalidSeekTime = false;
  330.       this._invalidSeekRecovery = false;
  331.       this._isLive = isLive != undefined ? isLive : false;
  332.       this._contentPath = url;
  333.       this._currentPos = 0;
  334.       this._streamLength = totalTime;
  335.       this._atEnd = false;
  336.       this._videoWidth = undefined;
  337.       this._videoHeight = undefined;
  338.       this._readyDispatched = false;
  339.       this._lastUpdateTime = -1;
  340.       this._sawSeekNotify = false;
  341.       clearInterval(this._updateTimeIntervalID);
  342.       this._updateTimeIntervalID = 0;
  343.       clearInterval(this._updateProgressIntervalID);
  344.       this._updateProgressIntervalID = 0;
  345.       clearInterval(this._idleTimeoutIntervalID);
  346.       this._idleTimeoutIntervalID = 0;
  347.       clearInterval(this._autoResizeIntervalID);
  348.       this._autoResizeIntervalID = 0;
  349.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  350.       this._rtmpDoStopAtEndIntervalID = 0;
  351.       clearInterval(this._rtmpDoSeekIntervalID);
  352.       this._rtmpDoSeekIntervalID = 0;
  353.       clearInterval(this._httpDoSeekIntervalID);
  354.       this._httpDoSeekIntervalID = 0;
  355.       clearInterval(this._finishAutoResizeIntervalID);
  356.       this._finishAutoResizeIntervalID = 0;
  357.       clearInterval(this._delayedBufferingIntervalID);
  358.       this._delayedBufferingIntervalID = 0;
  359.       this.closeNS(false);
  360.       if(this._ncMgr == null || this._ncMgr == undefined)
  361.       {
  362.          this.createINCManager();
  363.       }
  364.       var _loc2_ = this._ncMgr.connectToURL(this._contentPath);
  365.       this.setState(mx.video.VideoPlayer.LOADING);
  366.       this._cachedState = mx.video.VideoPlayer.LOADING;
  367.       if(_loc2_)
  368.       {
  369.          this._createStream();
  370.          this._setUpStream();
  371.       }
  372.       if(!this._ncMgr.isRTMP())
  373.       {
  374.          clearInterval(this._updateProgressIntervalID);
  375.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  376.       }
  377.    }
  378.    function pause()
  379.    {
  380.       if(!this.isXnOK())
  381.       {
  382.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined))
  383.          {
  384.             return undefined;
  385.          }
  386.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  387.       }
  388.       else
  389.       {
  390.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  391.          {
  392.             this._state = this._cachedState;
  393.          }
  394.          else
  395.          {
  396.             if(!this.__get__stateResponsive())
  397.             {
  398.                this.queueCmd(mx.video.VideoPlayer.PAUSE);
  399.                return undefined;
  400.             }
  401.             this.execQueuedCmds();
  402.          }
  403.          if(this._state == mx.video.VideoPlayer.PAUSED || this._state == mx.video.VideoPlayer.STOPPED || this._ns == null || this._ns == undefined)
  404.          {
  405.             return undefined;
  406.          }
  407.          this._pause(true);
  408.          this.setState(mx.video.VideoPlayer.PAUSED);
  409.       }
  410.    }
  411.    function stop()
  412.    {
  413.       if(!this.isXnOK())
  414.       {
  415.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined))
  416.          {
  417.             return undefined;
  418.          }
  419.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  420.       }
  421.       else
  422.       {
  423.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  424.          {
  425.             this._state = this._cachedState;
  426.          }
  427.          else
  428.          {
  429.             if(!this.__get__stateResponsive())
  430.             {
  431.                this.queueCmd(mx.video.VideoPlayer.STOP);
  432.                return undefined;
  433.             }
  434.             this.execQueuedCmds();
  435.          }
  436.          if(this._state == mx.video.VideoPlayer.STOPPED || this._ns == null || this._ns == undefined)
  437.          {
  438.             return undefined;
  439.          }
  440.          if(this._ncMgr.isRTMP())
  441.          {
  442.             if(this._autoRewind && !this._isLive)
  443.             {
  444.                this._currentPos = 0;
  445.                this._play(0,0);
  446.                this._state = mx.video.VideoPlayer.STOPPED;
  447.                this.setState(mx.video.VideoPlayer.REWINDING);
  448.             }
  449.             else
  450.             {
  451.                this.closeNS(true);
  452.                this.setState(mx.video.VideoPlayer.STOPPED);
  453.             }
  454.          }
  455.          else
  456.          {
  457.             this._pause(true);
  458.             if(this._autoRewind)
  459.             {
  460.                this._seek(0);
  461.                this._state = mx.video.VideoPlayer.STOPPED;
  462.                this.setState(mx.video.VideoPlayer.REWINDING);
  463.             }
  464.             else
  465.             {
  466.                this.setState(mx.video.VideoPlayer.STOPPED);
  467.             }
  468.          }
  469.       }
  470.    }
  471.    function seek(time)
  472.    {
  473.       if(this._invalidSeekTime)
  474.       {
  475.          return undefined;
  476.       }
  477.       if(isNaN(time) || time < 0)
  478.       {
  479.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_SEEK);
  480.       }
  481.       else if(!this.isXnOK())
  482.       {
  483.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined))
  484.          {
  485.             this.flushQueuedCmds();
  486.             this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  487.             this.setState(mx.video.VideoPlayer.LOADING);
  488.             this._cachedState = mx.video.VideoPlayer.LOADING;
  489.             this._ncMgr.reconnect();
  490.             return undefined;
  491.          }
  492.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  493.       }
  494.       else
  495.       {
  496.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  497.          {
  498.             this._state = this._cachedState;
  499.          }
  500.          else
  501.          {
  502.             if(!this.__get__stateResponsive())
  503.             {
  504.                this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  505.                return undefined;
  506.             }
  507.             this.execQueuedCmds();
  508.          }
  509.          if(this._ns == null || this._ns == undefined)
  510.          {
  511.             this._createStream();
  512.             this._video.attachVideo(this._ns);
  513.             this.attachAudio(this._ns);
  514.          }
  515.          if(this._atEnd && time < this.__get__playheadTime())
  516.          {
  517.             this._atEnd = false;
  518.          }
  519.          switch(this._state)
  520.          {
  521.             case mx.video.VideoPlayer.PLAYING:
  522.                this._state = mx.video.VideoPlayer.BUFFERING;
  523.             case mx.video.VideoPlayer.BUFFERING:
  524.             case mx.video.VideoPlayer.PAUSED:
  525.                this._seek(time);
  526.                this.setState(mx.video.VideoPlayer.SEEKING);
  527.                break;
  528.             case mx.video.VideoPlayer.STOPPED:
  529.                if(this._ncMgr.isRTMP())
  530.                {
  531.                   this._play(0);
  532.                   this._pause(true);
  533.                }
  534.                this._seek(time);
  535.                this._state = mx.video.VideoPlayer.PAUSED;
  536.                this.setState(mx.video.VideoPlayer.SEEKING);
  537.          }
  538.       }
  539.    }
  540.    function close()
  541.    {
  542.       this.closeNS(true);
  543.       if(this._ncMgr != null && this._ncMgr != undefined && this._ncMgr.isRTMP())
  544.       {
  545.          this._ncMgr.close();
  546.       }
  547.       this.setState(mx.video.VideoPlayer.DISCONNECTED);
  548.       this.dispatchEvent({type:"close",state:this._state,playheadTime:this.__get__playheadTime()});
  549.    }
  550.    function get x()
  551.    {
  552.       return this._x;
  553.    }
  554.    function set x(xpos)
  555.    {
  556.       this._x = xpos;
  557.    }
  558.    function get y()
  559.    {
  560.       return this._y;
  561.    }
  562.    function set y(ypos)
  563.    {
  564.       this._y = ypos;
  565.    }
  566.    function get scaleX()
  567.    {
  568.       return this._video._xscale;
  569.    }
  570.    function set scaleX(xs)
  571.    {
  572.       this.setScale(xs,this.__get__scaleY());
  573.    }
  574.    function get scaleY()
  575.    {
  576.       return this._video._yscale;
  577.    }
  578.    function set scaleY(ys)
  579.    {
  580.       this.setScale(this.__get__scaleX(),ys);
  581.    }
  582.    function get width()
  583.    {
  584.       return this._video._width;
  585.    }
  586.    function set width(w)
  587.    {
  588.       this.setSize(w,this._video._height);
  589.    }
  590.    function get height()
  591.    {
  592.       return this._video._height;
  593.    }
  594.    function set height(h)
  595.    {
  596.       this.setSize(this._video._width,h);
  597.    }
  598.    function get videoWidth()
  599.    {
  600.       if(this._readyDispatched)
  601.       {
  602.          this._videoWidth = this._video.width;
  603.       }
  604.       return this._videoWidth;
  605.    }
  606.    function get videoHeight()
  607.    {
  608.       if(this._readyDispatched)
  609.       {
  610.          this._videoHeight = this._video.height;
  611.       }
  612.       return this._videoHeight;
  613.    }
  614.    function get visible()
  615.    {
  616.       if(!this._hiddenForResize)
  617.       {
  618.          this.__visible = this._visible;
  619.       }
  620.       return this.__visible;
  621.    }
  622.    function set visible(v)
  623.    {
  624.       this.__visible = v;
  625.       if(!this._hiddenForResize)
  626.       {
  627.          this._visible = this.__visible;
  628.       }
  629.    }
  630.    function get autoSize()
  631.    {
  632.       return this._autoSize;
  633.    }
  634.    function set autoSize(flag)
  635.    {
  636.       if(this._autoSize != flag)
  637.       {
  638.          this._autoSize = flag;
  639.          if(this._autoSize)
  640.          {
  641.             this.startAutoResize();
  642.          }
  643.       }
  644.    }
  645.    function get maintainAspectRatio()
  646.    {
  647.       return this._aspectRatio;
  648.    }
  649.    function set maintainAspectRatio(flag)
  650.    {
  651.       if(this._aspectRatio != flag)
  652.       {
  653.          this._aspectRatio = flag;
  654.          if(this._aspectRatio && !this._autoSize)
  655.          {
  656.             this.startAutoResize();
  657.          }
  658.       }
  659.    }
  660.    function get autoRewind()
  661.    {
  662.       return this._autoRewind;
  663.    }
  664.    function set autoRewind(flag)
  665.    {
  666.       this._autoRewind = flag;
  667.    }
  668.    function get playheadTime()
  669.    {
  670.       var _loc2_ = !(this._ns == null || this._ns == undefined) ? this._ns.time : this._currentPos;
  671.       if(this._metadata.audiodelay != undefined)
  672.       {
  673.          _loc2_ -= this._metadata.audiodelay;
  674.          if(_loc2_ < 0)
  675.          {
  676.             _loc2_ = 0;
  677.          }
  678.       }
  679.       return _loc2_;
  680.    }
  681.    function set playheadTime(position)
  682.    {
  683.       this.seek(position);
  684.    }
  685.    function get url()
  686.    {
  687.       return this._contentPath;
  688.    }
  689.    function get volume()
  690.    {
  691.       return this._volume;
  692.    }
  693.    function set volume(aVol)
  694.    {
  695.       this._volume = aVol;
  696.       if(!this._hiddenForResize)
  697.       {
  698.          this._sound.setVolume(this._volume);
  699.       }
  700.    }
  701.    function get transform()
  702.    {
  703.       return this._sound.getTransform();
  704.    }
  705.    function set transform(s)
  706.    {
  707.       this._sound.setTransform(s);
  708.    }
  709.    function get isRTMP()
  710.    {
  711.       if(this._ncMgr == null || this._ncMgr == undefined)
  712.       {
  713.          return undefined;
  714.       }
  715.       return this._ncMgr.isRTMP();
  716.    }
  717.    function get isLive()
  718.    {
  719.       return this._isLive;
  720.    }
  721.    function get state()
  722.    {
  723.       return this._state;
  724.    }
  725.    function get stateResponsive()
  726.    {
  727.       switch(this._state)
  728.       {
  729.          case mx.video.VideoPlayer.DISCONNECTED:
  730.          case mx.video.VideoPlayer.STOPPED:
  731.          case mx.video.VideoPlayer.PLAYING:
  732.          case mx.video.VideoPlayer.PAUSED:
  733.          case mx.video.VideoPlayer.BUFFERING:
  734.             return true;
  735.          default:
  736.             return false;
  737.       }
  738.    }
  739.    function get bytesLoaded()
  740.    {
  741.       if(this._ns == null || this._ns == undefined || this._ncMgr.isRTMP())
  742.       {
  743.          return -1;
  744.       }
  745.       return this._ns.bytesLoaded;
  746.    }
  747.    function get bytesTotal()
  748.    {
  749.       if(this._ns == null || this._ns == undefined || this._ncMgr.isRTMP())
  750.       {
  751.          return -1;
  752.       }
  753.       return this._ns.bytesTotal;
  754.    }
  755.    function get totalTime()
  756.    {
  757.       return this._streamLength;
  758.    }
  759.    function get bufferTime()
  760.    {
  761.       return this._bufferTime;
  762.    }
  763.    function set bufferTime(aTime)
  764.    {
  765.       this._bufferTime = aTime;
  766.       if(this._ns != null && this._ns != undefined)
  767.       {
  768.          this._ns.setBufferTime(this._bufferTime);
  769.       }
  770.    }
  771.    function get idleTimeout()
  772.    {
  773.       return this._idleTimeoutInterval;
  774.    }
  775.    function set idleTimeout(aTime)
  776.    {
  777.       this._idleTimeoutInterval = aTime;
  778.       if(this._idleTimeoutIntervalID > 0)
  779.       {
  780.          clearInterval(this._idleTimeoutIntervalID);
  781.          this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  782.       }
  783.    }
  784.    function get playheadUpdateInterval()
  785.    {
  786.       return this._updateTimeInterval;
  787.    }
  788.    function set playheadUpdateInterval(aTime)
  789.    {
  790.       this._updateTimeInterval = aTime;
  791.       if(this._updateTimeIntervalID > 0)
  792.       {
  793.          clearInterval(this._updateTimeIntervalID);
  794.          this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  795.       }
  796.    }
  797.    function get progressInterval()
  798.    {
  799.       return this._updateProgressInterval;
  800.    }
  801.    function set progressInterval(aTime)
  802.    {
  803.       this._updateProgressInterval = aTime;
  804.       if(this._updateProgressIntervalID > 0)
  805.       {
  806.          clearInterval(this._updateProgressIntervalID);
  807.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  808.       }
  809.    }
  810.    function get ncMgr()
  811.    {
  812.       if(this._ncMgr == null || this._ncMgr == undefined)
  813.       {
  814.          this.createINCManager();
  815.       }
  816.       return this._ncMgr;
  817.    }
  818.    function get metadata()
  819.    {
  820.       return this._metadata;
  821.    }
  822.    function doUpdateTime()
  823.    {
  824.       var _loc2_ = this.__get__playheadTime();
  825.       switch(this._state)
  826.       {
  827.          case mx.video.VideoPlayer.STOPPED:
  828.          case mx.video.VideoPlayer.PAUSED:
  829.          case mx.video.VideoPlayer.DISCONNECTED:
  830.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  831.             clearInterval(this._updateTimeIntervalID);
  832.             this._updateTimeIntervalID = 0;
  833.       }
  834.       if(this._lastUpdateTime != _loc2_)
  835.       {
  836.          this.dispatchEvent({type:"playheadUpdate",state:this._state,playheadTime:_loc2_});
  837.          this._lastUpdateTime = _loc2_;
  838.       }
  839.    }
  840.    function doUpdateProgress()
  841.    {
  842.       if(this._ns == null || this._ns == undefined)
  843.       {
  844.          return undefined;
  845.       }
  846.       if(this._ns.bytesTotal >= 0 && this._ns.bytesTotal >= 0)
  847.       {
  848.          this.dispatchEvent({type:"progress",bytesLoaded:this._ns.bytesLoaded,bytesTotal:this._ns.bytesTotal});
  849.       }
  850.       if(this._state == mx.video.VideoPlayer.DISCONNECTED || this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ns.bytesLoaded == this._ns.bytesTotal)
  851.       {
  852.          clearInterval(this._updateProgressIntervalID);
  853.          this._updateProgressIntervalID = 0;
  854.       }
  855.    }
  856.    function rtmpOnStatus(info)
  857.    {
  858.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  859.       {
  860.          return undefined;
  861.       }
  862.       switch(info.code)
  863.       {
  864.          case "NetStream.Play.Stop":
  865.             if(this._startingPlay)
  866.             {
  867.                return undefined;
  868.             }
  869.             switch(this._state)
  870.             {
  871.                case mx.video.VideoPlayer.RESIZING:
  872.                   if(this._hiddenForResize)
  873.                   {
  874.                      this.finishAutoResize();
  875.                   }
  876.                   break;
  877.                case mx.video.VideoPlayer.LOADING:
  878.                case mx.video.VideoPlayer.STOPPED:
  879.                case mx.video.VideoPlayer.PAUSED:
  880.                   break;
  881.                default:
  882.                   this._sawPlayStop = true;
  883.             }
  884.             break;
  885.          case "NetStream.Buffer.Empty":
  886.             if(this._bufferState === mx.video.VideoPlayer.BUFFER_FULL)
  887.             {
  888.                if(this._sawPlayStop)
  889.                {
  890.                   this.rtmpDoStopAtEnd(true);
  891.                }
  892.                else if(this._state == mx.video.VideoPlayer.PLAYING)
  893.                {
  894.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  895.                }
  896.             }
  897.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  898.             this._sawPlayStop = false;
  899.             break;
  900.          case "NetStream.Buffer.Flush":
  901.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  902.             {
  903.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  904.                this._sawPlayStop = false;
  905.                this.setStateFromCachedState();
  906.                this.doUpdateTime();
  907.             }
  908.             if(this._sawPlayStop && (this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY || this._bufferTime <= 0.1 && this._ns.bufferLength <= 0.1))
  909.             {
  910.                this._cachedPlayheadTime = this.playheadTime;
  911.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  912.                this._rtmpDoStopAtEndIntervalID = setInterval(this,"rtmpDoStopAtEnd",mx.video.VideoPlayer.RTMP_DO_STOP_AT_END_INTERVAL);
  913.             }
  914.             if((_loc0_ = this._bufferState) !== mx.video.VideoPlayer.BUFFER_EMPTY)
  915.             {
  916.                if(this._state == mx.video.VideoPlayer.BUFFERING)
  917.                {
  918.                   this.setStateFromCachedState();
  919.                }
  920.             }
  921.             else
  922.             {
  923.                if(!this._hiddenForResize)
  924.                {
  925.                   if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  926.                   {
  927.                      this.setState(mx.video.VideoPlayer.PLAYING);
  928.                   }
  929.                   else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  930.                   {
  931.                      this._cachedState = mx.video.VideoPlayer.PLAYING;
  932.                   }
  933.                }
  934.                this._bufferState = mx.video.VideoPlayer.BUFFER_FLUSH;
  935.             }
  936.             break;
  937.          case "NetStream.Buffer.Full":
  938.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  939.             {
  940.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  941.                this._sawPlayStop = false;
  942.                this.setStateFromCachedState();
  943.                this.doUpdateTime();
  944.             }
  945.             switch(this._bufferState)
  946.             {
  947.                case mx.video.VideoPlayer.BUFFER_EMPTY:
  948.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  949.                   if(!this._hiddenForResize)
  950.                   {
  951.                      if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  952.                      {
  953.                         this.setState(mx.video.VideoPlayer.PLAYING);
  954.                      }
  955.                      else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  956.                      {
  957.                         this._cachedState = mx.video.VideoPlayer.PLAYING;
  958.                      }
  959.                      if(this._rtmpDoStopAtEndIntervalID != 0)
  960.                      {
  961.                         this._sawPlayStop = true;
  962.                         clearInterval(this._rtmpDoStopAtEndIntervalID);
  963.                         this._rtmpDoStopAtEndIntervalID = 0;
  964.                      }
  965.                   }
  966.                   break;
  967.                case mx.video.VideoPlayer.BUFFER_FLUSH:
  968.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  969.                   if(this._rtmpDoStopAtEndIntervalID != 0)
  970.                   {
  971.                      this._sawPlayStop = true;
  972.                      clearInterval(this._rtmpDoStopAtEndIntervalID);
  973.                      this._rtmpDoStopAtEndIntervalID = 0;
  974.                   }
  975.             }
  976.             if(this._state == mx.video.VideoPlayer.BUFFERING)
  977.             {
  978.                this.setStateFromCachedState();
  979.             }
  980.             break;
  981.          case "NetStream.Pause.Notify":
  982.             if(this._state == mx.video.VideoPlayer.RESIZING && this._hiddenForResize)
  983.             {
  984.                this.finishAutoResize();
  985.             }
  986.             break;
  987.          case "NetStream.Unpause.Notify":
  988.             if(this._state == mx.video.VideoPlayer.PAUSED)
  989.             {
  990.                this._state = mx.video.VideoPlayer.PLAYING;
  991.                this.setState(mx.video.VideoPlayer.BUFFERING);
  992.             }
  993.             else
  994.             {
  995.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  996.             }
  997.             break;
  998.          case "NetStream.Play.Start":
  999.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1000.             this._rtmpDoStopAtEndIntervalID = 0;
  1001.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1002.             this._sawPlayStop = false;
  1003.             if(this._startingPlay)
  1004.             {
  1005.                this._startingPlay = false;
  1006.                this._cachedPlayheadTime = this.playheadTime;
  1007.             }
  1008.             else if(this._state == mx.video.VideoPlayer.PLAYING)
  1009.             {
  1010.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1011.             }
  1012.             break;
  1013.          case "NetStream.Play.Reset":
  1014.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1015.             this._rtmpDoStopAtEndIntervalID = 0;
  1016.             if(this._state == mx.video.VideoPlayer.REWINDING)
  1017.             {
  1018.                clearInterval(this._rtmpDoSeekIntervalID);
  1019.                this._rtmpDoSeekIntervalID = 0;
  1020.                if(this.__get__playheadTime() == 0 || this.__get__playheadTime() < this._cachedPlayheadTime)
  1021.                {
  1022.                   this.setStateFromCachedState();
  1023.                }
  1024.                else
  1025.                {
  1026.                   this._cachedPlayheadTime = this.playheadTime;
  1027.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1028.                }
  1029.             }
  1030.             break;
  1031.          case "NetStream.Seek.Notify":
  1032.             if(this.__get__playheadTime() != this._cachedPlayheadTime)
  1033.             {
  1034.                this.setStateFromCachedState();
  1035.                this.doUpdateTime();
  1036.             }
  1037.             else
  1038.             {
  1039.                this._sawSeekNotify = true;
  1040.                if(this._rtmpDoSeekIntervalID == 0)
  1041.                {
  1042.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1043.                }
  1044.             }
  1045.             break;
  1046.          case "Netstream.Play.UnpublishNotify":
  1047.             break;
  1048.          case "Netstream.Play.PublishNotify":
  1049.             break;
  1050.          case "NetStream.Play.StreamNotFound":
  1051.             if(!this._ncMgr.connectAgain())
  1052.             {
  1053.                this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1054.             }
  1055.             break;
  1056.          case "NetStream.Play.Failed":
  1057.          case "NetStream.Failed":
  1058.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1059.       }
  1060.    }
  1061.    function httpOnStatus(info)
  1062.    {
  1063.       switch(info.code)
  1064.       {
  1065.          case "NetStream.Play.Stop":
  1066.             clearInterval(this._delayedBufferingIntervalID);
  1067.             this._delayedBufferingIntervalID = 0;
  1068.             if(this._invalidSeekTime)
  1069.             {
  1070.                this._invalidSeekTime = false;
  1071.                this._invalidSeekRecovery = true;
  1072.                this.setState(this._cachedState);
  1073.                this.seek(this.__get__playheadTime());
  1074.             }
  1075.             else
  1076.             {
  1077.                switch(this._state)
  1078.                {
  1079.                   case mx.video.VideoPlayer.PLAYING:
  1080.                   case mx.video.VideoPlayer.BUFFERING:
  1081.                   case mx.video.VideoPlayer.SEEKING:
  1082.                      this.httpDoStopAtEnd();
  1083.                }
  1084.             }
  1085.             break;
  1086.          case "NetStream.Seek.InvalidTime":
  1087.             if(this._invalidSeekRecovery)
  1088.             {
  1089.                this._invalidSeekTime = false;
  1090.                this._invalidSeekRecovery = false;
  1091.                this.setState(this._cachedState);
  1092.                this.seek(0);
  1093.             }
  1094.             else
  1095.             {
  1096.                this._invalidSeekTime = true;
  1097.             }
  1098.             break;
  1099.          case "NetStream.Buffer.Empty":
  1100.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1101.             if(this._state == mx.video.VideoPlayer.PLAYING)
  1102.             {
  1103.                clearInterval(this._delayedBufferingIntervalID);
  1104.                this._delayedBufferingIntervalID = setInterval(this,"doDelayedBuffering",this._delayedBufferingInterval);
  1105.             }
  1106.             break;
  1107.          case "NetStream.Buffer.Full":
  1108.          case "NetStream.Buffer.Flush":
  1109.             clearInterval(this._delayedBufferingIntervalID);
  1110.             this._delayedBufferingIntervalID = 0;
  1111.             this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1112.             if(!this._hiddenForResize)
  1113.             {
  1114.                if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  1115.                {
  1116.                   this.setState(mx.video.VideoPlayer.PLAYING);
  1117.                }
  1118.                else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  1119.                {
  1120.                   this._cachedState = mx.video.VideoPlayer.PLAYING;
  1121.                }
  1122.             }
  1123.             break;
  1124.          case "NetStream.Seek.Notify":
  1125.             this._invalidSeekRecovery = false;
  1126.             switch(this._state)
  1127.             {
  1128.                case mx.video.VideoPlayer.SEEKING:
  1129.                case mx.video.VideoPlayer.REWINDING:
  1130.                   if(this._httpDoSeekIntervalID == 0)
  1131.                   {
  1132.                      this._httpDoSeekCount = 0;
  1133.                      this._httpDoSeekIntervalID = setInterval(this,"httpDoSeek",mx.video.VideoPlayer.HTTP_DO_SEEK_INTERVAL);
  1134.                   }
  1135.             }
  1136.             break;
  1137.          case "NetStream.Play.StreamNotFound":
  1138.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1139.       }
  1140.    }
  1141.    function ncConnected()
  1142.    {
  1143.       if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  1144.       {
  1145.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1146.       }
  1147.       else
  1148.       {
  1149.          this._createStream();
  1150.          this._setUpStream();
  1151.       }
  1152.    }
  1153.    function ncReconnected()
  1154.    {
  1155.       if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  1156.       {
  1157.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1158.       }
  1159.       else
  1160.       {
  1161.          this._ns = null;
  1162.          this._state = mx.video.VideoPlayer.STOPPED;
  1163.          this.execQueuedCmds();
  1164.       }
  1165.    }
  1166.    function onMetaData(info)
  1167.    {
  1168.       if(this._metadata != null)
  1169.       {
  1170.          return undefined;
  1171.       }
  1172.       this._metadata = info;
  1173.       if(this._streamLength == undefined || this._streamLength == null || this._streamLength <= 0)
  1174.       {
  1175.          this._streamLength = info.duration;
  1176.       }
  1177.       if(isNaN(this._videoWidth) || this._videoWidth <= 0)
  1178.       {
  1179.          this._videoWidth = info.width;
  1180.       }
  1181.       if(isNaN(this._videoHeight) || this._videoHeight <= 0)
  1182.       {
  1183.          this._videoHeight = info.height;
  1184.       }
  1185.       this.dispatchEvent({type:"metadataReceived",info:info});
  1186.    }
  1187.    function onCuePoint(info)
  1188.    {
  1189.       if(!this._hiddenForResize || !isNaN(this._hiddenRewindPlayheadTime) && this.__get__playheadTime() < this._hiddenRewindPlayheadTime)
  1190.       {
  1191.          this.dispatchEvent({type:"cuePoint",info:info});
  1192.       }
  1193.    }
  1194.    function setState(s)
  1195.    {
  1196.       if(s == this._state)
  1197.       {
  1198.          return undefined;
  1199.       }
  1200.       this._hiddenRewindPlayheadTime = undefined;
  1201.       this._cachedState = this._state;
  1202.       this._cachedPlayheadTime = this.playheadTime;
  1203.       this._state = s;
  1204.       var _loc2_ = this._state;
  1205.       this.dispatchEvent({type:"stateChange",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1206.       if(!this._readyDispatched)
  1207.       {
  1208.          switch(_loc2_)
  1209.          {
  1210.             case mx.video.VideoPlayer.STOPPED:
  1211.             case mx.video.VideoPlayer.PLAYING:
  1212.             case mx.video.VideoPlayer.PAUSED:
  1213.             case mx.video.VideoPlayer.BUFFERING:
  1214.                this._readyDispatched = true;
  1215.                this.dispatchEvent({type:"ready",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1216.          }
  1217.       }
  1218.       if(this._cachedState === mx.video.VideoPlayer.REWINDING)
  1219.       {
  1220.          this.dispatchEvent({type:"rewind",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1221.          if(this._ncMgr.isRTMP() && _loc2_ == mx.video.VideoPlayer.STOPPED)
  1222.          {
  1223.             this.closeNS();
  1224.          }
  1225.       }
  1226.       switch(_loc2_)
  1227.       {
  1228.          case mx.video.VideoPlayer.STOPPED:
  1229.          case mx.video.VideoPlayer.PAUSED:
  1230.             if(this._ncMgr.isRTMP() && this._idleTimeoutIntervalID == 0)
  1231.             {
  1232.                this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  1233.             }
  1234.             break;
  1235.          case mx.video.VideoPlayer.SEEKING:
  1236.          case mx.video.VideoPlayer.REWINDING:
  1237.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1238.             this._sawPlayStop = false;
  1239.          case mx.video.VideoPlayer.PLAYING:
  1240.          case mx.video.VideoPlayer.BUFFERING:
  1241.             if(this._updateTimeIntervalID == 0)
  1242.             {
  1243.                this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  1244.             }
  1245.          case mx.video.VideoPlayer.LOADING:
  1246.          case mx.video.VideoPlayer.RESIZING:
  1247.             clearInterval(this._idleTimeoutIntervalID);
  1248.             this._idleTimeoutIntervalID = 0;
  1249.       }
  1250.       this.execQueuedCmds();
  1251.    }
  1252.    function setStateFromCachedState()
  1253.    {
  1254.       switch(this._cachedState)
  1255.       {
  1256.          case mx.video.VideoPlayer.PLAYING:
  1257.          case mx.video.VideoPlayer.PAUSED:
  1258.             this.setState(this._cachedState);
  1259.             break;
  1260.          case mx.video.VideoPlayer.BUFFERING:
  1261.             if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  1262.             {
  1263.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1264.             }
  1265.             else
  1266.             {
  1267.                this.setState(this._cachedState);
  1268.             }
  1269.             break;
  1270.          default:
  1271.             this.setState(mx.video.VideoPlayer.STOPPED);
  1272.       }
  1273.    }
  1274.    function createINCManager()
  1275.    {
  1276.       if(this.ncMgrClassName == null || this.ncMgrClassName == undefined)
  1277.       {
  1278.          this.ncMgrClassName = mx.video.VideoPlayer.DEFAULT_INCMANAGER;
  1279.       }
  1280.       var ncMgrConstructor = eval(this.ncMgrClassName);
  1281.       this._ncMgr = new ncMgrConstructor();
  1282.       this._ncMgr.setVideoPlayer(this);
  1283.    }
  1284.    function rtmpDoStopAtEnd(force)
  1285.    {
  1286.       if(this._rtmpDoStopAtEndIntervalID > 0)
  1287.       {
  1288.          switch(this._state)
  1289.          {
  1290.             case mx.video.VideoPlayer.DISCONNECTED:
  1291.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1292.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1293.                this._rtmpDoStopAtEndIntervalID = 0;
  1294.                return undefined;
  1295.             default:
  1296.                if(!(force || this._cachedPlayheadTime == this.__get__playheadTime()))
  1297.                {
  1298.                   this._cachedPlayheadTime = this.playheadTime;
  1299.                   return undefined;
  1300.                }
  1301.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1302.                this._rtmpDoStopAtEndIntervalID = 0;
  1303.          }
  1304.       }
  1305.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1306.       this._sawPlayStop = false;
  1307.       this._atEnd = true;
  1308.       this.setState(mx.video.VideoPlayer.STOPPED);
  1309.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1310.       {
  1311.          return undefined;
  1312.       }
  1313.       this.doUpdateTime();
  1314.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1315.       {
  1316.          return undefined;
  1317.       }
  1318.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.__get__playheadTime()});
  1319.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1320.       {
  1321.          return undefined;
  1322.       }
  1323.       if(this._autoRewind && !this._isLive && this.__get__playheadTime() != 0)
  1324.       {
  1325.          this._atEnd = false;
  1326.          this._currentPos = 0;
  1327.          this._play(0,0);
  1328.          this.setState(mx.video.VideoPlayer.REWINDING);
  1329.       }
  1330.       else
  1331.       {
  1332.          this.closeNS();
  1333.       }
  1334.    }
  1335.    function rtmpDoSeek()
  1336.    {
  1337.       if(this._state != mx.video.VideoPlayer.REWINDING && this._state != mx.video.VideoPlayer.SEEKING)
  1338.       {
  1339.          clearInterval(this._rtmpDoSeekIntervalID);
  1340.          this._rtmpDoSeekIntervalID = 0;
  1341.          this._sawSeekNotify = false;
  1342.       }
  1343.       else if(this.__get__playheadTime() != this._cachedPlayheadTime)
  1344.       {
  1345.          clearInterval(this._rtmpDoSeekIntervalID);
  1346.          this._rtmpDoSeekIntervalID = 0;
  1347.          this._sawSeekNotify = false;
  1348.          this.setStateFromCachedState();
  1349.          this.doUpdateTime();
  1350.       }
  1351.    }
  1352.    function httpDoStopAtEnd()
  1353.    {
  1354.       this._atEnd = true;
  1355.       if(this._streamLength == undefined || this._streamLength == null || this._streamLength <= 0)
  1356.       {
  1357.          this._streamLength = this._ns.time;
  1358.       }
  1359.       this._pause(true);
  1360.       this.setState(mx.video.VideoPlayer.STOPPED);
  1361.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1362.       {
  1363.          return undefined;
  1364.       }
  1365.       this.doUpdateTime();
  1366.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1367.       {
  1368.          return undefined;
  1369.       }
  1370.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.__get__playheadTime()});
  1371.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1372.       {
  1373.          return undefined;
  1374.       }
  1375.       if(this._autoRewind)
  1376.       {
  1377.          this._atEnd = false;
  1378.          this._pause(true);
  1379.          this._seek(0);
  1380.          this.setState(mx.video.VideoPlayer.REWINDING);
  1381.       }
  1382.    }
  1383.    function httpDoSeek()
  1384.    {
  1385.       var _loc2_ = this._state == mx.video.VideoPlayer.REWINDING || this._state == mx.video.VideoPlayer.SEEKING;
  1386.       if(_loc2_ && this._httpDoSeekCount < mx.video.VideoPlayer.HTTP_DO_SEEK_MAX_COUNT && (this._cachedPlayheadTime == this.__get__playheadTime() || this._invalidSeekTime))
  1387.       {
  1388.          this._httpDoSeekCount = this._httpDoSeekCount + 1;
  1389.          return undefined;
  1390.       }
  1391.       this._httpDoSeekCount = 0;
  1392.       clearInterval(this._httpDoSeekIntervalID);
  1393.       this._httpDoSeekIntervalID = 0;
  1394.       if(!_loc2_)
  1395.       {
  1396.          return undefined;
  1397.       }
  1398.       this.setStateFromCachedState();
  1399.       if(this._invalidSeekTime)
  1400.       {
  1401.          this._invalidSeekTime = false;
  1402.          this._invalidSeekRecovery = true;
  1403.          this.seek(this.__get__playheadTime());
  1404.       }
  1405.       else
  1406.       {
  1407.          this.doUpdateTime();
  1408.       }
  1409.    }
  1410.    function closeNS(updateCurrentPos)
  1411.    {
  1412.       if(this._ns != null && this._ns != undefined)
  1413.       {
  1414.          if(updateCurrentPos)
  1415.          {
  1416.             clearInterval(this._updateTimeIntervalID);
  1417.             this._updateTimeIntervalID = 0;
  1418.             this.doUpdateTime();
  1419.             this._currentPos = this._ns.time;
  1420.          }
  1421.          delete this._ns.onStatus;
  1422.          this._ns.onStatus = null;
  1423.          this._ns.close();
  1424.          this._ns = null;
  1425.       }
  1426.    }
  1427.    function doDelayedBuffering()
  1428.    {
  1429.       switch(this._state)
  1430.       {
  1431.          case mx.video.VideoPlayer.LOADING:
  1432.          case mx.video.VideoPlayer.RESIZING:
  1433.             break;
  1434.          case mx.video.VideoPlayer.PLAYING:
  1435.             clearInterval(this._delayedBufferingIntervalID);
  1436.             this._delayedBufferingIntervalID = 0;
  1437.             this.setState(mx.video.VideoPlayer.BUFFERING);
  1438.             break;
  1439.          default:
  1440.             clearInterval(this._delayedBufferingIntervalID);
  1441.             this._delayedBufferingIntervalID = 0;
  1442.       }
  1443.    }
  1444.    function _pause(doPause)
  1445.    {
  1446.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1447.       this._rtmpDoStopAtEndIntervalID = 0;
  1448.       this._ns.pause(doPause);
  1449.    }
  1450.    function _play()
  1451.    {
  1452.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1453.       this._rtmpDoStopAtEndIntervalID = 0;
  1454.       this._startingPlay = true;
  1455.       switch(arguments.length)
  1456.       {
  1457.          case 0:
  1458.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? 0 : -1,-1);
  1459.             break;
  1460.          case 1:
  1461.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,-1);
  1462.             break;
  1463.          case 2:
  1464.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,arguments[1]);
  1465.             break;
  1466.          default:
  1467.             throw new Error("bad args to _play");
  1468.       }
  1469.    }
  1470.    function _seek(time)
  1471.    {
  1472.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1473.       this._rtmpDoStopAtEndIntervalID = 0;
  1474.       if(this._metadata.audiodelay != undefined && time + this._metadata.audiodelay < this._streamLength)
  1475.       {
  1476.          time += this._metadata.audiodelay;
  1477.       }
  1478.       this._ns.seek(time);
  1479.       this._invalidSeekTime = false;
  1480.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1481.       this._sawPlayStop = false;
  1482.       this._sawSeekNotify = false;
  1483.    }
  1484.    function isXnOK()
  1485.    {
  1486.       if(this._state == mx.video.VideoPlayer.LOADING)
  1487.       {
  1488.          return true;
  1489.       }
  1490.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  1491.       {
  1492.          return false;
  1493.       }
  1494.       if(this._state != mx.video.VideoPlayer.DISCONNECTED)
  1495.       {
  1496.          if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined || !this._ncMgr.getNetConnection().isConnected)
  1497.          {
  1498.             this.setState(mx.video.VideoPlayer.DISCONNECTED);
  1499.             return false;
  1500.          }
  1501.          return true;
  1502.       }
  1503.       return false;
  1504.    }
  1505.    function startAutoResize()
  1506.    {
  1507.       switch(this._state)
  1508.       {
  1509.          case mx.video.VideoPlayer.DISCONNECTED:
  1510.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  1511.             return undefined;
  1512.          default:
  1513.             this._autoResizeDone = false;
  1514.             if(this.__get__stateResponsive() && this._videoWidth != undefined && this._videoHeight != undefined)
  1515.             {
  1516.                this.doAutoResize();
  1517.             }
  1518.             else
  1519.             {
  1520.                clearInterval(this._autoResizeIntervalID);
  1521.                this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1522.             }
  1523.       }
  1524.    }
  1525.    function doAutoResize()
  1526.    {
  1527.       if(this._autoResizeIntervalID > 0)
  1528.       {
  1529.          switch(this._state)
  1530.          {
  1531.             case mx.video.VideoPlayer.RESIZING:
  1532.             case mx.video.VideoPlayer.LOADING:
  1533.                break;
  1534.             case mx.video.VideoPlayer.DISCONNECTED:
  1535.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1536.                clearInterval(this._autoResizeIntervalID);
  1537.                this._autoResizeIntervalID = 0;
  1538.                return undefined;
  1539.             default:
  1540.                if(!this.__get__stateResponsive())
  1541.                {
  1542.                   return undefined;
  1543.                }
  1544.                break;
  1545.          }
  1546.          if(!(this._video.width != this._prevVideoWidth || this._video.height != this._prevVideoHeight || this._bufferState == mx.video.VideoPlayer.BUFFER_FULL || this._bufferState == mx.video.VideoPlayer.BUFFER_FLUSH || this._ns.time > mx.video.VideoPlayer.AUTO_RESIZE_PLAYHEAD_TIMEOUT))
  1547.          {
  1548.             return undefined;
  1549.          }
  1550.          if(this._hiddenForResize && this._metadata == null && this._hiddenForResizeMetadataDelay < mx.video.VideoPlayer.AUTO_RESIZE_METADATA_DELAY_MAX)
  1551.          {
  1552.             this._hiddenForResizeMetadataDelay = this._hiddenForResizeMetadataDelay + 1;
  1553.             return undefined;
  1554.          }
  1555.          this._videoWidth = this._video.width;
  1556.          this._videoHeight = this._video.height;
  1557.          clearInterval(this._autoResizeIntervalID);
  1558.          this._autoResizeIntervalID = 0;
  1559.       }
  1560.       if(!this._autoSize && !this._aspectRatio || this._autoResizeDone)
  1561.       {
  1562.          this.setState(this._cachedState);
  1563.          return undefined;
  1564.       }
  1565.       this._autoResizeDone = true;
  1566.       if(this._autoSize)
  1567.       {
  1568.          this._video._width = this._videoWidth;
  1569.          this._video._height = this._videoHeight;
  1570.       }
  1571.       else if(this._aspectRatio)
  1572.       {
  1573.          var _loc3_ = this._videoWidth * this.__get__height() / this._videoHeight;
  1574.          var _loc2_ = this._videoHeight * this.__get__width() / this._videoWidth;
  1575.          if(_loc2_ < this.__get__height())
  1576.          {
  1577.             this._video._height = _loc2_;
  1578.          }
  1579.          else if(_loc3_ < this.__get__width())
  1580.          {
  1581.             this._video._width = _loc3_;
  1582.          }
  1583.       }
  1584.       if(this._hiddenForResize)
  1585.       {
  1586.          this._hiddenRewindPlayheadTime = this.playheadTime;
  1587.          if(this._state == mx.video.VideoPlayer.LOADING)
  1588.          {
  1589.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1590.          }
  1591.          if(!this._ncMgr.isRTMP())
  1592.          {
  1593.             this._pause(true);
  1594.             this._seek(0);
  1595.             clearInterval(this._finishAutoResizeIntervalID);
  1596.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1597.          }
  1598.          else if(!this._isLive)
  1599.          {
  1600.             this._currentPos = 0;
  1601.             this._play(0,0);
  1602.             this.setState(mx.video.VideoPlayer.RESIZING);
  1603.          }
  1604.          else if(this._autoPlay)
  1605.          {
  1606.             clearInterval(this._finishAutoResizeIntervalID);
  1607.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1608.          }
  1609.          else
  1610.          {
  1611.             this.finishAutoResize();
  1612.          }
  1613.       }
  1614.       else
  1615.       {
  1616.          this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1617.       }
  1618.    }
  1619.    function finishAutoResize()
  1620.    {
  1621.       clearInterval(this._finishAutoResizeIntervalID);
  1622.       this._finishAutoResizeIntervalID = 0;
  1623.       if(this.__get__stateResponsive())
  1624.       {
  1625.          return undefined;
  1626.       }
  1627.       this._visible = this.__visible;
  1628.       this._sound.setVolume(this._volume);
  1629.       this._hiddenForResize = false;
  1630.       this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1631.       if(this._autoPlay)
  1632.       {
  1633.          if(this._ncMgr.isRTMP())
  1634.          {
  1635.             if(!this._isLive)
  1636.             {
  1637.                this._currentPos = 0;
  1638.                this._play(0);
  1639.             }
  1640.             if(this._state == mx.video.VideoPlayer.RESIZING)
  1641.             {
  1642.                this.setState(mx.video.VideoPlayer.LOADING);
  1643.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1644.             }
  1645.          }
  1646.          else
  1647.          {
  1648.             this._pause(false);
  1649.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1650.          }
  1651.       }
  1652.       else
  1653.       {
  1654.          this.setState(mx.video.VideoPlayer.STOPPED);
  1655.       }
  1656.    }
  1657.    function _createStream()
  1658.    {
  1659.       this._ns = new NetStream(this._ncMgr.getNetConnection());
  1660.       this._ns.mc = this;
  1661.       if(this._ncMgr.isRTMP())
  1662.       {
  1663.          this._ns.onStatus = function(info)
  1664.          {
  1665.             this.mc.rtmpOnStatus(info);
  1666.          };
  1667.       }
  1668.       else
  1669.       {
  1670.          this._ns.onStatus = function(info)
  1671.          {
  1672.             this.mc.httpOnStatus(info);
  1673.          };
  1674.       }
  1675.       this._ns.onMetaData = function(info)
  1676.       {
  1677.          this.mc.onMetaData(info);
  1678.       };
  1679.       this._ns.onCuePoint = function(info)
  1680.       {
  1681.          this.mc.onCuePoint(info);
  1682.       };
  1683.       this._ns.setBufferTime(this._bufferTime);
  1684.    }
  1685.    function _setUpStream()
  1686.    {
  1687.       this._video.attachVideo(this._ns);
  1688.       this.attachAudio(this._ns);
  1689.       if(!isNaN(this._ncMgr.getStreamLength()) && this._ncMgr.getStreamLength() >= 0)
  1690.       {
  1691.          this._streamLength = this._ncMgr.getStreamLength();
  1692.       }
  1693.       if(!isNaN(this._ncMgr.getStreamWidth()) && this._ncMgr.getStreamWidth() >= 0)
  1694.       {
  1695.          this._videoWidth = this._ncMgr.getStreamWidth();
  1696.       }
  1697.       else
  1698.       {
  1699.          this._videoWidth = undefined;
  1700.       }
  1701.       if(!isNaN(this._ncMgr.getStreamHeight()) && this._ncMgr.getStreamHeight() >= 0)
  1702.       {
  1703.          this._videoHeight = this._ncMgr.getStreamHeight();
  1704.       }
  1705.       else
  1706.       {
  1707.          this._videoHeight = undefined;
  1708.       }
  1709.       if((this._autoSize || this._aspectRatio) && this._videoWidth != undefined && this._videoHeight != undefined)
  1710.       {
  1711.          this._prevVideoWidth = undefined;
  1712.          this._prevVideoHeight = undefined;
  1713.          this.doAutoResize();
  1714.       }
  1715.       if(!this._autoSize && !this._aspectRatio || this._videoWidth != undefined && this._videoHeight != undefined)
  1716.       {
  1717.          if(this._autoPlay)
  1718.          {
  1719.             if(!this._ncMgr.isRTMP())
  1720.             {
  1721.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1722.                this._play();
  1723.             }
  1724.             else if(this._isLive)
  1725.             {
  1726.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1727.                this._play(-1);
  1728.             }
  1729.             else
  1730.             {
  1731.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1732.                this._play(0);
  1733.             }
  1734.          }
  1735.          else
  1736.          {
  1737.             this._cachedState = mx.video.VideoPlayer.STOPPED;
  1738.             if(this._ncMgr.isRTMP())
  1739.             {
  1740.                this._play(0,0);
  1741.             }
  1742.             else
  1743.             {
  1744.                this._play();
  1745.                this._pause(true);
  1746.                this._seek(0);
  1747.             }
  1748.          }
  1749.       }
  1750.       else
  1751.       {
  1752.          if(!this._hiddenForResize)
  1753.          {
  1754.             this.__visible = this._visible;
  1755.             this._visible = false;
  1756.             this._volume = this._sound.getVolume();
  1757.             this._sound.setVolume(0);
  1758.             this._hiddenForResize = true;
  1759.          }
  1760.          this._hiddenForResizeMetadataDelay = 0;
  1761.          this._play(0);
  1762.          if(this._currentPos > 0)
  1763.          {
  1764.             this._seek(this._currentPos);
  1765.             this._currentPos = 0;
  1766.          }
  1767.       }
  1768.       clearInterval(this._autoResizeIntervalID);
  1769.       this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1770.    }
  1771.    function doIdleTimeout()
  1772.    {
  1773.       clearInterval(this._idleTimeoutIntervalID);
  1774.       this._idleTimeoutIntervalID = 0;
  1775.       this.close();
  1776.    }
  1777.    function flushQueuedCmds()
  1778.    {
  1779.       while(this._cmdQueue.length > 0)
  1780.       {
  1781.          this._cmdQueue.pop();
  1782.       }
  1783.    }
  1784.    function execQueuedCmds()
  1785.    {
  1786.       while(this._cmdQueue.length > 0 && (this.__get__stateResponsive() || this._state == mx.video.VideoPlayer.CONNECTION_ERROR) && (this._cmdQueue[0].url != null && this._cmdQueue[0].url != undefined || this._state != mx.video.VideoPlayer.DISCONNECTED && this._state != mx.video.VideoPlayer.CONNECTION_ERROR))
  1787.       {
  1788.          var _loc2_ = this._cmdQueue.shift();
  1789.          this._cachedState = this._state;
  1790.          this._state = mx.video.VideoPlayer.EXEC_QUEUED_CMD;
  1791.          switch(_loc2_.type)
  1792.          {
  1793.             case mx.video.VideoPlayer.PLAY:
  1794.                this.play(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1795.                break;
  1796.             case mx.video.VideoPlayer.LOAD:
  1797.                this.load(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1798.                break;
  1799.             case mx.video.VideoPlayer.PAUSE:
  1800.                this.pause();
  1801.                break;
  1802.             case mx.video.VideoPlayer.STOP:
  1803.                this.stop();
  1804.                break;
  1805.             case mx.video.VideoPlayer.SEEK:
  1806.                this.seek(_loc2_.time);
  1807.                break;
  1808.          }
  1809.       }
  1810.    }
  1811.    function queueCmd(type, url, isLive, time)
  1812.    {
  1813.       this._cmdQueue.push({type:type,url:url,isLive:false,time:time});
  1814.    }
  1815. }
  1816.